############################################################
#Replication: Walter et al. Non-Cooperation by popular vote#
#														   #
#             International Organization                   #
############################################################



#Please read readme.txt before using this file.



set more off

clear


cd "/path/to/replication/directory/"

use DataSet_Referendum_Sat5July15.dta,clear



gen contref_no=4 if VoteRef==2
replace contref_no=1 if VoteRef==1
replace contref_no=2 if VoteRef==44
replace contref_no=3 if VoteRef==55
replace contref_no=. if VoteRef>56

gen refall=contref_no
replace refall=5 if contref>56
label def refall 1 "Yes" 2 "Prob. Yes" 3 "Prob. No" 4 "No" 5 "Undec./Abstain"
label val refall refall

label def exp 1 "Grext" 2 "Negotiations" 88 "DK/DA"
label val expectations exp


gen referendumno=VoteRef==2
replace referendumno=1 if VoteRef==55

gen referendumyes=VoteRef==1
replace referendumyes=1 if VoteRef==44

gen referendumundecided=VoteRef>56

* change of opinion?
gen bankholidaychange=CapitalControls==1

* Stay or leave Euro?
gen stayeuro=europreferences==1
gen leaveeuro=europreferences==2
gen eurodontknow=europreferences==88

 
 * Euro and EU
 gen euroandeu=BestForGr==1
 gen eunoteuro=BestForGr==2
 gen noneeueuro=BestForGr==3
 gen noanswer=BestForGr==88
 
 * beliefs on no consequences
 gen grexitbelief=expectations==1
 gen negotiationbelief=expectations==2
 gen uncertainconsequences=expectations==88
 
 * education dummy
 gen highedu=EduRec==4
 
 * recode occupation (additional categories possible)
 gen unemployed=Occupation==20
 gen publicsector=Occupation==1
 gen privatesector=Occupation==2
 gen pensioner=Occupation==3
 replace pensioner=1 if Occupation==4
 gen entrepreneur=Occupation==5
 replace entrepreneur=1 if Occupation==6 // self-employed recoded as entrepreneur
 *gen housechores=Occupation==7 
 gen farmer=Occupation==9
 gen otherocc=Occupation==10
 replace otherocc=1 if Occupation==50 
 replace otherocc=1 if Occupation==7
 
 * recode partisanship
 gen nd=PastVoteJan2015==1
 gen syriza=PastVoteJan2015==2
 gen pasok=PastVoteJan2015==3
 gen anel=PastVoteJan2015==4
 gen goldendawn=PastVoteJan2015==5
 gen river=PastVoteJan2015==14
 gen abstain=PastVoteJan2015==77
 gen other=0
*replace other=1 if PastVot>14 & PastVot<77 ***Use this one if we want to code as missing those that DK/DA
replace other=1 if PastVot>14 &  PastVot<77
replace other=1 if PastVot<14 &  PastVot>5
replace other=1 if PastVot>77

gen vote=7 
replace vote=1 if PastVoteJan2015==2 
replace vote=2 if PastVoteJan2015==4 
replace vote=3 if PastVoteJan2015==3 
replace vote=4 if PastVoteJan2015==1 
replace vote=5 if PastVoteJan2015==14 
replace vote=6 if PastVoteJan2015==5 
replace vote=8 if PastVoteJan2015==77 // abstain

label def vote 1 "Syriza" 2 "ANEL" 3 "PASOK" 4 "Nea Democratia" 5 "To Potami" 6 "Golden Dawn" 7 "others" 8 "abstain"
label val vote vote

 
 
gen vote2=. //government
replace vote2=1 if vote<3 //government
replace vote2=2 if vote>2 & vote<6 // moderate opposition
replace vote2=2 if vote==7 // moderate opposition
replace vote2=3 if vote==6 // Golden Dawn
label def vote2 1 "Government" 2 "Moderate Opposition" 3 "Golden Dawn" 
label val vote2 vote2


* Other controls
* ------------------------
gen rural=Region==2
gen female=Gender==2


* Negotiation and Grexit without DK/DA
gen negotiationvsgrexit=expectations
	replace negotiationvsgrexit=. if expectations==88
	replace negotiationvsgrexit=negotiationvsgrexit-1

svyset quid [pweight = sexage3weight]


*********

* Table A.1 DESCRIPTIVE VARIABLES
sum referendumno
sum grexitb
sum negotiationb
sum EduR
sum Age
sum female
sum rural
sum unemployed
sum publicsector
sum privatesector
sum pensioner
sum entrepreneur
sum farmer
sum otherocc
sum bankholidaychange 
sum syriza
sum anel
sum nd
sum pasok
sum river
sum goldendawn
sum abstain
sum stayeuro
sum leaveeuro


saveold withvars.dta, version(12) replace




*********************************
*Figure 1: See Figure1.xlsx file*
*********************************

*********************************
*Figure 2: See Figure2.xlsx file*
*********************************

*****************************************
*Figure 3: See ReplicationIO_WDJK.R file*
*****************************************

**********
*Figure 4*
**********


xi: svy: logit referendumno grexitbelief negotiationbelief i.Age unemployed  public private entrepreneur farmer  otherocc i.EduRec/*
*/  female rural syriza anel pasok river goldendawn abstain other leaveeuro stayeuro  
margins, dydx(*) 

parmest ,bmat(r(b)) vmat(r(V)) label saving(results6, replace)
use results6, clear

gen id=_n




sort id




gen id3=28-id

recode id3 (26=26)(27=27)(1=25)(2=24)(9=23) (8=22) (7=21) (6=20) (5=19) (4=18) (3=17) (25=16) (24=15) (23=14) (22=13) (21=12) (20=11) (19=10) (18=9) (17=8) (16=7) (15=6) (14=5) (13=4) (12=3) (11=2) (10=1),into(id4)
sort id4
label define results 27 "Grexit" 26 "Negotiations" 16 "25-34" 15 "35-44" 14 "45-54" 13 "55-64" 12 "Above 65"/*
*/ 11 "Unemployed" 10 "Public Sector" 9 "Private Sector" 8 "Entrepreneur" 7 "Farmer" /*
*/ 6 "Other Occupation" 5 "High-School" 4 "Post-H.S." 3 "University" /*
*/ 2 "Female" 1 "Rural" 23 "Syriza" 22 "ANEL" 21 "PASOK" 20 "Potami" 19 "Golden Dawn" 18 "Abstain" /*
*/ 17 "Other" 24 "Leave Euro" 25 "Stay Euro" 

label values id4 results 
sort id4
saveold resultsFig4,replace version(12)


**********
*Figure 5*
**********

use withvars.dta, clear

ta EduRec,gen(ed)
ta Age,gen(age)

logit grexitbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro
 
predict prscore



ebalance grexitbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain prscore/*
 */ other stayeuro leaveeuro, keep(baltable1) replace



svyset [pweight=_webal]
svy: reg referendumn grexitbelief
parmest ,bmat(e(b)) vmat(e(V)) label saving(match1,  replace)



keep referendumn grexitbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore


foreach x of varlist  referendumn grexitbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore {
keep if `x'!= .
}
 
export delimited using genmatch1.csv,  delimiter(tab) replace


use withvars.dta, clear

ta EduRec,gen(ed)
ta Age,gen(age)

logit negotiationbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro
 
predict prscore

ebalance negotiationbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain prscore/*
 */ other stayeuro leaveeuro, keep(baltable2) replace



svyset [pweight=_webal]
svy: reg referendumn negotiationbelief
parmest ,bmat(e(b)) vmat(e(V)) label saving(match2,  replace)


keep referendumn negotiationbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore


foreach x of varlist  referendumn negotiationbelief age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore {
keep if `x'!= .
}
 
export delimited using genmatch2.csv,  delimiter(tab) replace

use match1, clear
gen id=_n
keep if id==1
keep estimate min95 max95 id
rename estimate est 
saveold match1n,version(12) replace 

use match2, clear
gen id=_n
keep if id==1
keep estimate min95 max95 id
rename estimate est 
saveold match2n,version(12) replace 

*See Matching.R for the graph.

**********
*Figure 6*
**********




use withvars.dta, clear

local controls "Age unemployed public private  entrepreneur farmer otherocc EduRec female rural"
local parties "syriza anel nd pasok river goldendawn abstain"


svy: logit referendumno grexitb##i.stay   negotiationb##i.stay      `controls' `parties'

**Figure 7: Estimates
margins stay , dydx(grexitb negotiationb)

margins stay, dydx(grexitb negotiationb) 
*est store indicator
parmest ,bmat(r(b)) vmat(r(V)) label saving(results2, replace)
use results2, clear
drop if estimate==0
gen id=_n
recode id (1=1)(2=5)(3=2) (4=6),into(stayeuro)
recode id (1=1)(2=1)(3=2) (4=2),into(expectations)
label define exp 1 "Anti-euro" 2 "Pro-euro"
label values expectations exp 
saveold interpref.dta,version(12) replace









**********
*Figure 7*
**********


*See ReplicationIO_WDJK.R












**********
*Figure 8*
**********



use withvars.dta, clear


gen expectationsreferendum=expectations 
char expectations[omit] 88 
est clear



xi: svy: mlogit expectationsr bankho i.Age unemployed  public private entrepreneur farmer  otherocc i.EduRec/*
*/  female rural syriza anel pasok river goldendawn abstain other leaveeuro stayeuro  , base (88)
margins, dydx(*) 
*est store indicator
parmest ,bmat(r(b)) vmat(r(V)) label saving(results2, replace)
use results2, clear

gen id=_n

sort eq parm 
bysort eq:gen id2=_n


drop if id2==3

sort id
save results3, replace

drop if id2==2
sort id
save results4, replace

use results3, clear
drop if id2==1
sort id
save results5, replace

use results4, clear 


gen id3=27-_n
recode id3 (26=26) (1=25)(2=24)(9=23) (8=22) (7=21) (6=20) (5=19) (4=18) (3=17) (25=16) (24=15) (23=14) (22=13) (21=12) (20=11) (19=10) (18=9) (17=8) (16=7) (15=6) (14=5) (13=4) (12=3) (11=2) (10=1),into(id4)
label define results 26 "Bank Holiday" 25 "25-34" 24 "35-44" 23 "45-54" 22 "55-64" 21 "Above 65"/*
*/ 20 "Unemployed" 19 "Public Sector" 18 "Private Sector" 17 "Entrepreneur" 16 "Farmer" /*
*/ 15 "Other Occupation" 14 "High-School" 13 "Post-H.S." 12 "University" /*
*/ 11 "Female" 10 "Rural" 9 "Syriza" 8 "ANEL" 7 "PASOK" 6 "Potami" 5 "Golden Dawn" 4 "Abstain" /*
*/ 3 "Other" 2 "Leave Euro" 1 "Stay Euro" 



label values id4 results 

saveold results8a,replace version(12)

use results5, clear

gen id3=27-_n
recode id3 (26=26) (1=25)(2=24)(9=23) (8=22) (7=21) (6=20) (5=19) (4=18) (3=17) (25=16) (24=15) (23=14) (22=13) (21=12) (20=11) (19=10) (18=9) (17=8) (16=7) (15=6) (14=5) (13=4) (12=3) (11=2) (10=1),into(id4)
label define results 26 "Bank Holiday" 25 "25-34" 24 "35-44" 23 "45-54" 22 "55-64" 21 "Above 65"/*
*/ 20 "Unemployed" 19 "Public Sector" 18 "Private Sector" 17 "Entrepreneur" 16 "Farmer" /*
*/ 15 "Other Occupation" 14 "High-School" 13 "Post-H.S." 12 "University" /*
*/ 11 "Female" 10 "Rural" 9 "Syriza" 8 "ANEL" 7 "PASOK" 6 "Potami" 5 "Golden Dawn" 4 "Abstain" /*
*/ 3 "Other" 2 "Leave Euro" 1 "Stay Euro" 

label values id4 results 

saveold results8b,replace version(12)



**********
*Appendix*
**********

use withvars.dta, clear

	* Table A.1 DESCRIPTIVE VARIABLES
	sum referendumno
	sum grexitb
	sum negotiationb
	sum EduR
	sum Age
	sum female
	sum rural
	sum unemployed
	sum publicsector
	sum privatesector
	sum pensioner
	sum entrepreneur
	sum farmer
	sum otherocc
	sum bankholidaychange 
	sum syriza
	sum anel
	sum nd
	sum pasok
	sum river
	sum goldendawn
	sum abstain
	sum stayeuro
	sum leaveeuro

*Table A.2 Determinants of NoVote


local controls "i.Age unemployed public private entrepreneur farmer otherocc EduRec female rural"
local parties "syriza anel pasok river goldendawn abstain other"
local euro "stayeuro leaveeuro"
 
svy: logit referendumno grexitbelief negotiationbelief 

svy: logit referendumno grexitbelief negotiationbelief `controls'

svy: logit referendumno grexitbelief negotiationbelief  `controls'  `parties'

svy: logit referendumno grexitbelief negotiationbelief  `controls'  `parties' `euro'

svy: logit referendumno grexitb##i.stay   negotiationb##i.stay      `controls' `parties'



 

***** TABLE A.3

char expectations[omit] 88 

svy: mlogit  expectations bankh  , base(88)
outreg2 using TableA3.doc, replace
svy: mlogit  expectations  bankh  i.Age unemployed public private entrepreneur farmer otherocc EduRec female rural  syriza anel pasok river goldendawn abstain other ,base(88)
outreg2 using TableA3.doc, append
svy: mlogit  expectations  bankh  i.Age unemployed public private entrepreneur farmer otherocc EduRec female rural  syriza anel pasok river goldendawn abstain other stayeuro leaveeuro ,base(88)
outreg2 using TableA3.doc, append




******************
*Figure A1 and A2*
******************

*See Matching.R


***********
*Figure A3*
***********


use baltable1.dta,clear
gen id=_n


twoway scatter id sdiff_Pre, xlabel(-1(.5)1) name(graph1, replace)/*
*/ title("Before Entropy Balancing") scheme(s1color) aspect(1) xline(0,lcolor(black)) /*
*/ mcolor(black) msymbol(oh)
twoway scatter id sdiff_Post, xlabel(-1(.5)1) name(graph2, replace)/*
*/ title("After Entropy Balancing") scheme(s1color) aspect(1) xline(0,lcolor(black)) /*
*/ mcolor(black) msymbol(oh)


graph combine graph1 graph2


***********
*Figure A4*
***********


use baltable2.dta,clear
gen id=_n


twoway scatter id sdiff_Pre, xlabel(-1(.5)1) name(graph1, replace)/*
*/ title("Before Entropy Balancing") scheme(s1color) aspect(1) xline(0,lcolor(black)) /*
*/ mcolor(black) msymbol(oh)
twoway scatter id sdiff_Post, xlabel(-1(.5)1) name(graph2, replace)/*
*/ title("After Entropy Balancing") scheme(s1color) aspect(1) xline(0,lcolor(black)) /*
*/ mcolor(black) msymbol(oh)


graph combine graph1 graph2



***********
*Figure A5*
***********


*See Matching.R


*******************
*Figures A6 and A7*
*******************




use withvars.dta, clear

ta EduRec,gen(ed)
ta Age,gen(age)

logit bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro
 
predict prscore2

ebalance bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain prscore2/*
 */ other stayeuro leaveeuro, keep(baltable3) replace

 



svyset [pweight=_webal]
svy: reg grexitbelief bankholidaychange
parmest ,bmat(e(b)) vmat(e(V)) label saving(match3,  replace)



keep grexitbelief bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore2


foreach x of varlist  grexitbelief bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore2 {
keep if `x'!= .

}
 
export delimited using genmatch3.csv,  delimiter(tab) replace



use match3, clear
gen id1=_n
keep if id1==1
gen id2=1
keep estimate min95 max95 id1 id2
rename estimate est 
saveold match3n,version(12) replace 





use withvars.dta, clear

ta EduRec,gen(ed)
ta Age,gen(age)

logit bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro
 
predict prscore3

ebalance bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain prscore3/*
 */ other stayeuro leaveeuro, keep(baltable4) replace

 



svyset [pweight=_webal]
svy: reg negotiationbelief bankholidaychange
parmest ,bmat(e(b)) vmat(e(V)) label saving(match4,  replace)



keep negotiationbelief bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore3


foreach x of varlist  negotiationbelief bankholidaychange age1-age6 ed1-ed4 unemployed public private entrepreneur farmer otherocc /*
  */ female rural syriza anel pasok river goldendawn abstain /*
 */ other stayeuro leaveeuro prscore3 {
keep if `x'!= .

}
 
export delimited using genmatch4.csv,  delimiter(tab) replace




use match4, clear
gen id1=_n
keep if id1==1
gen id2=2
keep estimate min95 max95 id1 id2
rename estimate est 
saveold match4n,version(12) replace 

*See Matching.R for the final graphs.

***********
*Figure A8*
***********


use Experiment.dta, clear


gen varouf=0
replace varouf=1 if Exp2==1 | Exp2==2 | Exp2==3

gen sch=0
replace sch=1 if Exp2==4 | Exp2==5 | Exp2==6

gen dr=0
replace dr=1 if Exp2==7 | Exp2==9 | Exp2==9


gen pay=6-ResExp_2 if ResExp_2<6


reg pay varouf sch dr ,robust
estimates store oldest
lincomest  varouf 
parmest,label saving(schauble1.dta,replace)  
estimates restore oldest

estimates store oldest
lincomest  dr 
parmest,label saving(schauble2.dta,replace)  
estimates restore oldest

estimates store oldest
lincomest  sch 
parmest,label saving(schauble3.dta,replace)  
estimates restore oldest

use schauble1, clear
forvalues x=2/3 {
append using schauble`x'.dta
}

gen id=_n

gen id2=4-_n

saveold schaub,version(12) replace

*See ReplicationIO_WDJK.R for the final graphs.

***********
*Table A7**
***********



use withvars.dta, clear

keep referendumno grexitbelief bankholidaychange
foreach x of varlist referendumno grexitbelief bankholidaychange {

keep if `x'!= .

}

saveold mediat, version(12) replace

*See ReplicationIO_WDJK.R for the final estimates.
